<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of categorias_model
 *
 * @author Lucas Pinheiro
 */
class Banners_model extends MY_Model {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->banco = null;
        $this->tabela = 'banners_tbl';
        $this->apelido = 'ba';
    }

    public function randon() {
        $query = $this->db->query('SELECT *
FROM ' . ($this->banco != null ? $this->banco . '.' : '') . $this->tabela . ' as ' . $this->apelido . '
ORDER BY RAND()
LIMIT 1');
        if ($query->num_rows() > 0) {
            return $query->row();
        } else {
            return NULL;
        }
    }

}